<template>
  <div>
    <!-- 列表页面 -->
    <div class="container" >
      <div class="header"><div class="title">货品列表</div></div>
      <!-- 表格 -->
      <lin-table
        :tableColumn="tableColumn"
        :tableData="tableData"
        :operate="operate"
        @handleEdit="handleEdit"
        @handleDelete="handleDelete"
        @row-click="rowClick"
        v-loading="loading"
      ></lin-table>
    </div>

<!--    &lt;!&ndash; 编辑页面 &ndash;&gt;-->
<!--    <book-modify v-else @editClose="editClose" :editBookID="editBookID"></book-modify>-->
<!--    <button>sssdsdas</button>-->
  </div>
</template>

<script>

import LinTable from '@/component/base/table/lin-table'
import shopStock from '@/model/shopStock'


export default {
  name: 'shop-stock-list',
  components: {
    LinTable,
  },
  data() {
    return {
      tableColumn: [{ prop: 'goods_id', label: '商品号' },{ prop: 'goods_name', label: '商品名' }, { prop: 'goods_price', label: '售价' }, { prop: 'stock_value', label: '库存量' }, { prop: 'shop_name', label: '商店' }],
      tableData: [],
      operate: [],
      showEdit: false,
      editBookID: 1,
      loading: false
    }
  },
  async mounted() {
    this.loading = true
    await this.getStocks()
    this.operate = [

    ]
    this.loading = false
    console.log(this.tableData)
  },

  methods: {
    async getStocks() {
      try {
        const shopStocks = await shopStock.getShopStocks()
        this.tableData = shopStocks
        console.log(shopStocks)
      } catch (error) {
        if (error.code === 10020) {
          this.tableData = []
        }
      }
    },
    handleEdit(val) {
      // console.log('val', val)
      // this.showEdit = true
      // this.editBookID = val.row.id
    },
    handleDelete(val) {
      // this.$confirm('此操作将永久删除该图书, 是否继续?', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   type: 'warning',
      // }).then(async () => {
      //   const res = await book.deleteBook(val.row.id)
      //   if (res.code < window.MAX_SUCCESS_CODE) {
      //     this.getBooks()
      //     this.$message({
      //       type: 'success',
      //       message: `${res.message}`,
      //     })
      //   }
      // })
    },
    rowClick() {
      console.log('rowclick')
    },
    editClose() {
      // this.showEdit = false
      // this.getBooks()
    },
  },
}
</script>

<style lang="scss" scoped>
.container {
  padding: 0 30px;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .title {
      height: 59px;
      line-height: 59px;
      color: $parent-title-color;
      font-size: 16px;
      font-weight: 500;
    }
  }

  .pagination {
    display: flex;
    justify-content: flex-end;
    margin: 20px;
  }
}
</style>
